package com.yanqu.road.entity.activity.biaoju.config;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.config.system.NormalWeightItem;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.math.BigInteger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

@FieldTypeAnnotation(tableName = "t_s_activity_biaoju_title", desc = "镖局镖师表")
public class BiaoJuTitleConfig extends DataObject {
    @FieldTypeAnnotation(select = true, isIndex = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "镖师Id", isIndex = true)
    private int id;
    @FieldTypeAnnotation(desc = "镖师名称")
    private String name;
    @FieldTypeAnnotation(desc = "镖师介绍")
    private String desc;
    @FieldTypeAnnotation(desc = "图标")
    private String icon;
    @FieldTypeAnnotation(desc = "升级经验（当前级所需的累计押镖经验")
    private int cost;
    @FieldTypeAnnotation(desc = "结算加成（千分比")
    private int incomeAdd;
    @FieldTypeAnnotation(desc = "战力")
    private int power;
    @FieldTypeAnnotation(desc = "权重（品质;权重|品质;权重")
    private String weights;
    @FieldTypeAnnotation(desc = "刷新的镖单数量")
    private int refreshNum;
    @FieldTypeAnnotation(desc = "高级镖系数（镖单品质；镖师系数)用于动态生成")
    private String highDartParam;

    private List<NormalWeightItem> weightList = new ArrayList<>();

    private Property highDartParamProperty = new Property();

    public BiaoJuTitleConfig(ResultSet rs) throws SQLException {
        this.activityId = rs.getInt("activityId");
        this.id = rs.getInt("id");
        this.name = rs.getString("name");
        this.desc = rs.getString("desc");
        this.icon = rs.getString("icon");
        this.cost = rs.getInt("cost");
        this.incomeAdd = rs.getInt("incomeAdd");
        this.power = rs.getInt("power");
        this.weights = rs.getString("weights");
        this.refreshNum = rs.getInt("refreshNum");
        this.highDartParam = rs.getString("highDartParam");

        String[] split = this.weights.split("\\|");
        for (String s : split) {
            List<Integer> list = StringUtils.stringToIntegerList(s, ";");
            weightList.add(new NormalWeightItem(BigInteger.valueOf(list.get(0)), list.get(1)));
        }

        this.highDartParamProperty = PropertyHelper.parseStringToProperty(highDartParam);
    }

    public int getActivityId() {
        return activityId;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    public String getIcon() {
        return icon;
    }

    public int getCost() {
        return cost;
    }

    public int getIncomeAdd() {
        return incomeAdd;
    }

    public int getPower() {
        return power;
    }

    public String getWeights() {
        return weights;
    }

    public List<NormalWeightItem> getWeightList() {
        return weightList;
    }

    public int getRefreshNum() {
        return refreshNum;
    }

    public String getHighDartParam() {
        return highDartParam;
    }

    public Property getHighDartParamProperty() {
        return highDartParamProperty;
    }
}
